function lucid_goUpdateObservers()
{
    document.getElementById('lucidbc_clearcache').hidden = lucidapi.isPassphraseCacheEmpty();
//        document.getElementById('lucidcmd_clearcache').setAttribute("disabled", lucidapi.isPassphraseCacheEmpty() ? "true" : "false" );
}

function lucid_goUpdateWrapperCommands()
{
    for (var ii = 0; ii < arguments.length; ii++)
    {
        var cmd = arguments[ii];
        var wrapper = document.getElementById("lucid" + cmd);
        if (wrapper)
        {
            var disabled = true;
            var controller = document.commandDispatcher.getControllerForCommand(cmd);
            if (controller && controller.isCommandEnabled(cmd)){
                disabled = false;
            }
            wrapper.setAttribute("disabled", (disabled ? "true" : "false") );
        }
    }
}

function lucid_goUpdateCommands()
{
    try {
        var cmdlist = [
            "encrypt",
            "decrypt",
            "verify",
            "import"
        ];
        var anyshowing = false;
        for (var ii = 0; ii < cmdlist.length; ii++)
        {
            var cmd = "lucidcmd_" + cmdlist[ii];
            var wrapper = document.getElementById(cmd);
            if (wrapper)
            {
                var disabled = true;
                var controller = document.commandDispatcher.getControllerForCommand(cmd);
                if (controller && controller.isCommandEnabled(cmd)){
                    disabled = false;
                }
                wrapper.setAttribute("disabled", (disabled ? "true" : "false") );
                var bc = document.getElementById('lucidbc_' + cmdlist[ii]);
                if (bc)
                {
                    bc.hidden = disabled;
//                    lucidapi.debug("setting %s.%s to %s", window.id, cmd, disabled);
                    anyshowing = disabled ? anyshowing : true;
                }
            }
        }
        bc = document.getElementById('lucidbc_contextseparator');
        if (bc)
            bc.hidden = !anyshowing;
    } catch (e) {
        Components.utils.reportError(e);
    }
}

function lucid_showSysPopup()
{
    var statpanel = document.getElementById("lucidity-statuspanel");
    var syspopup = document.getElementById("lucid-syspopup");
    syspopup.openPopup(statpanel, "before_end", 0, 0, false, false);
}
